package font;

import java.awt.image.BufferedImage;
import java.io.File;

import javax.imageio.ImageIO;

import define.ErrorDefine;

import main.ErrorException;

public class ImageInfo implements RegionAble
{
	public int m_x;
	public int m_y;
	public int m_w;
	public int m_h;
	
	public String m_name;
	public StringBuffer m_path;
	
	public ImageInfo(StringBuffer path, String name)
	{
		m_name = name;
		m_path = path;
	}
	
	public void setWH(int padding) throws ErrorException
	{
		try 
		{
			BufferedImage image = ImageIO.read(new File(m_path.toString()));
			m_w = image.getWidth() + padding;
			m_h = image.getHeight() + padding;
		}
		catch(Exception e) 
		{
			throw new ErrorException(ErrorDefine.E_CANT_READ_IMAGE_ERROR, m_path.toString());
		}
	}

	public int getWidth()
	{
		return m_w;
	}

	public int getHeight() 
	{
		return m_h;
	}

	public void setCoo(Region r)
	{
		m_x = r.m_left;
		m_y = r.m_top;
	}

	public int getArea()
	{
		return m_w * m_h;
	}
}
